package com.csw.shuanfa.utils.jwt;


import io.jsonwebtoken.Claims;
import io.jsonwebtoken.impl.TextCodec;

import java.util.Arrays;

public class CreateJjwt {
    public static void main(String[] args) {
        String key = TextCodec.BASE64.encode("miyao");
        JwtUtil jwtUtil = new JwtUtil();
        //要传进去加密的key
        String token = jwtUtil.createjwt("666", "csw", "admin", key, 10);
        System.out.println(token);

        //应为同一个字符串，就算后面拼接了东西，解密后效果一样
        System.out.println(Arrays.toString(TextCodec.BASE64.decode(key)));
        System.out.println(Arrays.toString(TextCodec.BASE64.decode(key+"XXX")));


        Claims claims = jwtUtil.parsejwt(token, key);

        System.out.println("id]" + claims.getId());
        System.out.println("账号】" + claims.getSubject());
        System.out.println("签发时间】" + claims.getIssuedAt());
        System.out.println("角色】" + claims.get("roles"));


    }

}
